var slides = new Array
var curSlideIdx
var running = false

function addSlide(imgName)
{
    //if (slides.indexOf(slidePath) != -1)
    //    return;
    slides.push(imgName)
}

function removeSlide(imgName)
{
    var idx = slides.indexOf(imgName)
    if (idx === -1)
        return;
    slides.splice(idx, 1);
    if (slides.length === 0) {
        running = false;
    }
}

function startSlideshow()
{
    if (slides.length <= 0)
        return;
    curSlideIdx = 0;
    running = true;
    slide.source = "image://cache/" + slides[curSlideIdx];
    slide.startAnimation();
    slide.started = true
}

function stopSlideshow()
{
    running = false;
    slide.stopAnimation();
    slide.started = false
}

function onSlideShowed()
{
    if (!running) return;
    if (++curSlideIdx >= slides.length)
        curSlideIdx = 0;
    slide.source = "image://cache/" + slides[curSlideIdx];
    slide.startAnimation();
}
